<!DOCTYPE html>
<html xmlns:th="http://www.theymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>公告</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/font_eolqem241z66flxr.css"
          media="all"/>

</head>
<body>


<form class="layui-form" lay-filter="formtable">
    <div class="layui-form-item">
        <label class="layui-form-label">客户使用说明:</label>
        <div class="layui-input-block text1">
            <textarea placeholder="请输入内容" class="layui-textarea" name="msg" id="msg"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="adddd">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="/layui/layui.js"></script>
<script src="https://unpkg.com/wangeditor@3.1.1/release/wangEditor.min.js"></script>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
    var E = window.wangEditor;
    // var editor = new E('#editor')
    var editor = new E(document.getElementById('editor'));
    editor.customConfig.uploadImgShowBase64 = true;   // 使用 base64 保存图片
    var text1 = $('#text1');
    editor.customConfig.onchange = function (html) {
        // 监控变化，同步更新到 textarea
        text1.val (html);
        alert(html)
    };
    editor.create();
    text1.val (editor.txt.html());
</script>
<script type="text/javascript"  >

    layui
        .config({
            base: "js/"
        })
        .use(
            ['form', 'layer', 'jquery', 'layedit', 'laydate', 'upload'],
            function () {
                var form = layui.form, layer = layui.layer, laypage = layui.laypage, layedit = layui.layedit,
                    laydate = layui.laydate, $ = layui.jquery, upload = layui.upload;

                function getUParam(name, id) {
                    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); // 构造一个含有目标参数的正则表达式对象
                    var r = decodeURIComponent(
                        $("#" + id).attr("src").substr(
                            $("#" + id).attr("src").indexOf("?"))
                            .substr(1)).match(reg); // 匹配目标参数
                    if (r != null)
                        return unescape(r[2]);
                    return ""; // 返回参数值
                }

                var id = "[[${modyid}]]";


                // 监听提交
                form.on('submit(adddd)', function (data) {
                    parent.resetSwClose(true);
                    layer.msg('正在保存。。。', {time: 1000}, function () {
                    });
                    var url = "";
                    if (id != null && id != '')
                        url = "/gg/update";
                    else
                        url ="/gg/add";
                    $.getJSON(url, data.field,
                        function (data) {
                            if (data.code == '200') {
                                parent.layer.closeAll();
                                parent.reloadList();
                            } else {
                                layer.msg('数据保存失败', {
                                    time: 1000
                                }, function () {
                                    alert(300)
                                });
                                parent.resetSwClose(false);
                            }
                        });
                    return false;
                });
                //获取信息
                if (id != null && id != '') {
                    $.getJSON("/gg/get", "id=" + id, function (jsondata) {
                        if (jsondata.code == '200') {
                            console.log(JSON.stringify(jsondata.data));
                            //表单初始赋值
                            form.val('formtable', JSON.parse(JSON.stringify(jsondata.data)));
                        } else {
                            $("#subpost").attr("disabled", "disabled").addClass("layui-btn-disabled");
                            layer.msg(jsondata.msg, {time: 2000}, function () {
                                parent.layer.closeAll('iframe');
                            });
                        }
                    });
                }


            })

</script>

</body>
</html>